package cn.mapway.ib.client.main;

import cn.mapway.ib.client.rpc.AppInstallProxy;
import cn.mapway.ib.client.widget.DirSelector;
import cn.mapway.ib.share.model.common.ApiResult;
import cn.mapway.ib.share.model.common.ResultCode;
import cn.mapway.ib.share.model.dir.DirFile;
import cn.mapway.ui.client.widget.buttons.AiButton;
import cn.mapway.ui.client.widget.dialog.Dialog;
import com.google.gwt.core.client.Callback;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.*;

public class MainWindowsFrame extends Composite {
    private static final MainWindowsFrameUiBinder ourUiBinder = GWT.create(MainWindowsFrameUiBinder.class);
    @UiField
    VerticalPanel list;
    @UiField
    AiButton btnPathSelect;
    @UiField
    TextBox txtPath;

    public MainWindowsFrame() {
        initWidget(ourUiBinder.createAndBindUi(this));
    }

    @Override
    protected void onLoad() {
        super.onLoad();
    }


    @UiHandler("btnPathSelect")
    public void btnPathSelectClick(ClickEvent event) {
        Dialog<DirSelector> dialog = DirSelector.getDialog(true);
        dialog.addCommonHandler(commonEvent -> {
            if (commonEvent.isOk()) {
                txtPath.setValue(commonEvent.getValue());
            }
            dialog.hide();
        });
        dialog.center();
    }

    interface MainWindowsFrameUiBinder extends UiBinder<DockLayoutPanel, MainWindowsFrame> {
    }
}